package com.dbq.share;

import android.os.Parcel;
import android.os.Parcelable;

import static com.dbq.share.SocializeMediaConstant.COPY;
import static com.dbq.share.SocializeMediaConstant.FACEBOOK;
import static com.dbq.share.SocializeMediaConstant.QQ;
import static com.dbq.share.SocializeMediaConstant.QZONE;
import static com.dbq.share.SocializeMediaConstant.SINA;
import static com.dbq.share.SocializeMediaConstant.WEIXIN;
import static com.dbq.share.SocializeMediaConstant.WEIXIN_TIMELINE;

/**
 * Created by sunkai on 2017/12/26.
 */

class ShareTarget implements Parcelable {
    public int titleId;
    public int iconId;
    public @SocializeMedia
    String media;

    public ShareTarget(@SocializeMedia String media) {
        this.media = media;
        switch (media) {
            case SINA:
                init(R.string.dbq_socialize_text_sina_key, R.drawable.dbq_socialize_sina_on);
                break;
            case WEIXIN:
                init(R.string.dbq_socialize_text_weixin_key, R.drawable.dbq_socialize_wechat);
                break;
            case WEIXIN_TIMELINE:
                init(R.string.dbq_socialize_text_weixin_circle_key, R.drawable.dbq_socialize_wxcircle);
                break;
            case QQ:
                init(R.string.dbq_socialize_text_qq_key, R.drawable.dbq_socialize_qq_on);
                break;
            case QZONE:
                init(R.string.dbq_socialize_text_qq_zone_key, R.drawable.dbq_socialize_qzone_on);
                break;
            case FACEBOOK:
                init(R.string.dbq_socialize_text_facebook_key, R.drawable.dbq_socialize_facebook);
                break;
            case COPY:
                init(R.string.dbq_socialize_text_copy_url, R.drawable.dbq_socialize_copy_url);
                break;

        }

    }

    public ShareTarget() {

    }

    protected ShareTarget(Parcel in) {
        titleId = in.readInt();
        iconId = in.readInt();
        media = in.readString();
    }

    public static final Creator<ShareTarget> CREATOR = new Creator<ShareTarget>() {
        @Override
        public ShareTarget createFromParcel(Parcel in) {
            return new ShareTarget(in);
        }

        @Override
        public ShareTarget[] newArray(int size) {
            return new ShareTarget[size];
        }
    };

    private void init(int titleId, int iconId) {
        this.titleId = titleId;
        this.iconId = iconId;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(titleId);
        dest.writeInt(iconId);
        dest.writeString(media);
    }
}
